package com.yzp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Description
 *
 * @className: OrderController
 * @author: yanzhouping
 * @date: 2019/9/20 20:11
 */
@RestController
@RequestMapping("/orderManagement")
public class OrderController {


    /**
     * RestTemplate 是由SpringBoot Web组件提供 默认整合ribbon负载均衡器
     * rest方式地层是采用httpclient技术
     */
    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/getInfo")
    public String getNumber() {
        return "我是订单微服务";
    }

    @RequestMapping("/getOrder")
    public String getOrder() {
        String url = "http://zk-user/userManagement/getInfo";
        String result = restTemplate.getForObject(url, String.class);
        System.out.println("订单中心调用用户中心结果：" + result);
        return "订单中心调用用户中心结果:"+result;
    }

}
